package com.appcheck.recording.handler.impl;

import com.appcheck.recording.action.AbstractAction;
import com.appcheck.recording.action.ActionConvert;
import com.appcheck.recording.action.impl.ClickAction;
import com.appcheck.recording.action.impl.DateChangedAction;
import com.appcheck.recording.action.impl.FocusAction;
import com.appcheck.recording.action.impl.ItemClickAction;
import com.appcheck.recording.action.impl.ItemSelectedAction;
import com.appcheck.recording.action.impl.KeyAction;
import com.appcheck.recording.action.impl.OrientationChangeAction;
import com.appcheck.recording.action.impl.ScrollListAction;
import com.appcheck.recording.action.impl.ScrollStateChangedAction;
import com.appcheck.recording.action.impl.TextChangedAction;
import com.appcheck.recording.action.impl.TimeChangedAction;
import com.appcheck.recording.action.impl.TouchAction;
import com.appcheck.recording.handler.AbstractActionHandler;
import com.appcheck.recording.handler.action.TextEnteredAction;
import com.appcheck.recording.plugin.AbstractActionConverter;
import com.appcheck.recording.plugin.ActionConverter;
import com.appcheck.recording.utils.Logger;
/**
 * visit方法如果返回true说明不继续处理，返回false说明需要传递给下一个handler
 * @author dell
 *
 */
public class Grouper implements AbstractActionHandler {
	
	private Grouper nextGrouper;
	private AbstractActionConverter actionConverter = new ActionConverter();
	
	public Grouper(Grouper paramGrouper) {
		this.nextGrouper = paramGrouper;
	}
	@Override
	public void processAction(AbstractAction action) {
		if((!action.handle(this)) && (this.nextGrouper != null)) {
			this.nextGrouper.processAction(action);
		}
	}
	
	public void forwardActionToPlugin(ActionConvert action){
		Logger.INFO(String.format("forwarded action to plugin: %s", new Object[] { action.toString() }));
		action.toTestCode(actionConverter);
	}
	
	public void forwardActionToConverter(ActionConvert action){
		action.toTestCode(actionConverter);
	}

	@Override
	public boolean visit(ClickAction clickAction) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean visit(DateChangedAction dataChangedAction) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean visit(TouchAction touchAction) {
		// TODO Auto-generated method stub
		return false;
	}
	@Override
	public boolean visit(ItemClickAction itemClickAction) {
		// TODO Auto-generated method stub
		return false;
	}
	@Override
	public boolean visit(ScrollListAction scrollListAction) {
		// TODO Auto-generated method stub
		return false;
	}
	@Override
	public boolean visit(ScrollStateChangedAction scrollStateChangedAction) {
		// TODO Auto-generated method stub
		return false;
	}
	@Override
	public boolean visit(KeyAction keyAction) {
		// TODO Auto-generated method stub
		return false;
	}
	@Override
	public boolean visit(TextChangedAction textChangedAction) {
		// TODO Auto-generated method stub
		return false;
	}
	@Override
	public boolean visit(FocusAction focusAction) {
		// TODO Auto-generated method stub
		return false;
	}
	@Override
	public boolean visit(ItemSelectedAction itemSelectedAction) {
		// TODO Auto-generated method stub
		return false;
	}
	@Override
	public boolean visit(TimeChangedAction timeChangedAction) {
		// TODO Auto-generated method stub
		return false;
	}

	public void forwardActionToConverter(TextEnteredAction textEnteredAction) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public boolean visit(OrientationChangeAction orientationChangeAction) {
		// TODO Auto-generated method stub
		return false;
	}

}
